﻿/********************************************************************************************************************
* Author:	Christos Polydorou																						*
* Email:	std04237@di.uoa.gr																						*
* Purpose:	This script is used in order to create the "Attributes" table that holds all attributes.				*
********************************************************************************************************************/

CREATE TABLE [dbo].[Attributes]
(
	ID bigint PRIMARY KEY NOT NULL IDENTITY(1,1),								/* The id of the attribute */
	Category bigint NOT NULL,													/* The category it bellongs to */
	Name nvarchar(50) NOT NULL,													/* The name of the attribute */
	Type char(1) NOT NULL,														/* The type of the attribute */
	BestValue char(3) NULL,													/* The direction of the best value (eg min,max,rel) */
	FOREIGN KEY (Category) REFERENCES Categories(ID),
	CONSTRAINT UniqueNameForAttribute UNIQUE (Category,Name)					/* The name of an attribute must be unique for the specific category */
)
